/*
 * @Description: 托盘功能
 * @Date: 2024-09-30 14:09:29
 * @FilePath: \demod:\12electron\b站向军课程\electron-camera\src\main\tray.ts
 */
import { Menu, Tray } from 'electron'
import path from 'path'

const createTray = () => {
  // 苹果的系统托盘图标要求是黑白色的，win系统则可以是彩色的
  const tray = new Tray(
    path.resolve(
      __dirname,
      process.platform == 'darwin' ? '../../resources/fish.png' : '../../resources/fish.png'
    )
  )

  // 定义托盘的菜单
  const contextMenu = Menu.buildFromTemplate([
    { label: '退出', role: 'quit' },
    {
      label: '其他',
      click: () => {
        console.log('其他')
      }
    }
  ])
  tray.setToolTip('electron-camera')
  tray.setContextMenu(contextMenu)
}

export default createTray
